Show warning message if initial_parameters is passed instead of initial_params - #176
Conversation
|
AbstractMCMC.jl documentation for PR #176 is available at: |
6068582 to
42e519b
Compare
There was a problem hiding this comment.
Thanks @shravanngoswamii -- there is one thing missing here, namely that single-chain sampling doesn't issue a warning.
using AbstractMCMC
struct M <: AbstractMCMC.AbstractModel end
struct S <: AbstractMCMC.AbstractSampler end
AbstractMCMC.step(rng, ::M, ::S, state=nothing; kwargs...) = rand(rng), nothing
sample(M(), S(), 5; initial_parameters=42.42)Now if you were to copy-paste the warning inside the method for mcmcsample, my guess is that you will probably find that multiple-chain sampling
sample(M(), S(), MCMCThreads(), 10, 3; initial_parameters=42.42)will issue a warning (nchains+1) times, because the keyword arguments are passed straight on to single-chain sample.
So, if I'm not wrong, in the multiple-chain sampling when you are performing this check you should also make sure that initial_parameters is removed from kwargs after issuing the warning, e.g. using:
kwargs = BangBang.delete!!(kwargs, :initial_parameters)(I hunted around for a base Julia way of removing a key from a NamedTuple, but it's not released yet: JuliaLang/julia#55270 so I think BangBang is needed.)
|
Hi @penelopeysm, the Also, I noticed something in the |
initial_parameters is passed instead of initial_params
|
Oh, yes, good catch. Sure, the DynamicPPL bit has similar problems to what I described here too (including with removing the keyword argument). But if the warning is in AbstractMCMC, then there's no need for the DynamicPPL one, and I can just remove it. |
Okay, let's merge it! |
|
Will merge when CI passes, thanks @shravanngoswamii! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #176 +/- ##
===========================
===========================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Closes #175